-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the hashCode
and equals
methods in Transaction
and FeeBumpTransaction
.
#566
Fix the hashCode
and equals
methods in Transaction
and FeeBumpTransaction
.
#566
Conversation
@@ -15,8 +15,7 @@ | |||
import org.stellar.sdk.xdr.TransactionSignaturePayload; | |||
|
|||
/** Abstract class for transaction classes. */ | |||
@EqualsAndHashCode(exclude = {"accountConverter"}) | |||
// TODO: maybe we should not exclude accountConverter from equals and hashCode | |||
@EqualsAndHashCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will introduce non-deterministic equality or false mis-matches on equals/hash? since AccountConverter is a stateless function not a value object, it can produce the same output account values whether it's enableMuxed
property is true or false when the incoming accounts of the tx are edd25519, this would result in the a sub-class object instance with AccountConverter(enabledMuxed=false) to not match based on equals/hash to another instance of same sub-class but with AccountConverter(enabledMuxed=true), even though both of those instances will result in generated the exact same tx xdr via toXdr()
.
I'm wondering if this abstract tx class should even have an equals/hash code implementation at all, b/c the subclasses of this should decide how tx instance state is created for equals/hash.
Further, it seems like lombok @EqualsAndHashCode
which derives instance equality from member value comparisons alone is not well suited for Transaction sub classes(Transaction and FeeBumpTransaction) equality, since subclass instance state does not represent the complete value of a stellar transaction yet, correct? What do you think about the equals/hash of Transaction and FeeBumpTransaction using the output of toXdr()
as instance value instead of member values? since that compiled xdr value represents an instance's true stellar transaction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing this out, comparing XDR objects is indeed a good approach, and I have already made the modification.
accountConverter
to the equals
and hashCode
of AbstractTransaction
.hashCode
and equals
methods in Transaction
and FeeBumpTransaction
.
hashCode
and equals
methods in Transaction
and FeeBumpTransaction
.hashCode
and equals
methods in Transaction
and FeeBumpTransaction
.
…Transaction`, now they will compare based on the `signatureBase()`.
# Conflicts: # CHANGELOG.md # src/main/java/org/stellar/sdk/Transaction.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks for discussion on tx equals/hash
Fix the
hashCode
andequals
methods inTransaction
andFeeBumpTransaction
, now they will compare based on thesignatureBase()
.